package com.tiger.utils;

import com.alibaba.fastjson.JSON;
import com.tiger.pojo.chat.ResultMessage;

/**
 * @author HuXuehao (StudiousTiger)
 * @desc 这个类的作用是 封装消息的工具类
 * @date 2022/3/17
 */
public class MessageUtils {

    public static String getMessage(boolean isSystemMessage, String fromName, Object message){
        try {
            ResultMessage resultMessage = new ResultMessage();
            resultMessage.setSystem(isSystemMessage);
            if (fromName != null){
                resultMessage.setFromName(fromName);
            }
            resultMessage.setMessage(message);

            return JSON.toJSONString(resultMessage);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }


    }
}
